<?php

$this->breadcrumbs = array(
    'Ruang Rapat' => $this->createUrl('/' . $this->module->id . '/default/index'),
    'Search Meeting Room',
);

Yii::app()->clientScript->registerScript('search', "
/*$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('rapat-grid', {
		data: $(this).serialize()
	});
	return false;
});*/

/*$(this).delegate('#date-rapat-form', 'change', function(e){
    $.fn.yiiGridView.update('rapat-grid');
});*/

setInterval(function(){
        $.fn.yiiGridView.update('rapat-grid');
}, 60000);

// TODO masih kotor
jQuery('#rapat-grid input[name=\'RuanganRapat[date]\']').datepicker({'dateFormat':'dd/mm/yy'});
");

?>

<?php $this->renderPartial('smartSearch', array('model' => $model)); ?>

<div class="form">
    <fieldset>
        <legend>Pencarian Lanjut</legend>
    <?php
    $this->beginWidget('zii.widgets.grid.CGridView', array(
        'id' => 'rapat-grid',
        'dataProvider' => $dataProvider,
        'filter' => $model,
        'afterAjaxUpdate' => "
            function(id, data){
                // TODO masih kotor
                jQuery('#rapat-grid input[name=\'RuanganRapat[date]\']').datepicker({'dateFormat':'dd/mm/yy'});
            }",
        'columns' => array(
            array(
                'header' => 'Tanggal',
                'name' => 'date',
                'value' => '',
            ),
            array(
                'name' => 'name',
             ),
            array(
                'name' => 'floor.building.name',
                'filter' => CHtml::activeTextField($model, 'building_name'),
            ),
            array(
                'name' => 'floor.floor_number',
                'filter' => CHtml::activeTextField($model, 'floor_number'),
             ),
            'capacity',
            array(
                'header' => 'Status',
                'filter' => CHtml::activeTextField($model, 'status'),
                'value' => '$data->getStatus("' . $model->date . '")',
                'type' => 'raw',
            ),
            array(
                'header' => 'Action',
                'class' => 'CButtonColumn',
                'template' => '{booking}',
                'buttons' => array(
                    'booking' => array(
                        'label' => 'Booking',
                        'imageUrl' => $this->module->assetsUrl . "/images/book.png",
                        'url' => '$this->grid->controller->createUrl("request/create?date=' . $model->date . '&time_start=' . $model->time_start . '&time_end=' . $model->time_end . '&room_id=$data->id&participant=' . $model->participant . '")',
                        ),
                    ),
                ),
            ),
        ));
    ?>
    <?php
    $this->endWidget();
    ?>
    </fieldset>
</div>